
class Dog{
    /*
    先使用public,稍后进行讲解
    这里的name,age,sex都是成员变量(也称字段)
     */
    public String name;
    public int age;
    public String sex;
    /*
    这里的eat,bark都是成员方法(也称行为)
     */
    public void eat(){
        System.out.println(name + "吃狗粮！");
    }
    public void bark(){
        System.out.println(name + "汪汪叫！");
    }
}

class Student{
    public String name;
    public int age;
    public String sex;
    //通过get方法给变量赋值
 /*   public void get(String name, int age, String sex){
        name = name;
        age = age;
        sex = sex;
    }*/
    public void get(String a, int b, String c){
        name = a;
        age = b;
        sex = c;
    }
}
public class Test {
    public static void main(String[] args) {
        Student student = new Student();
        student.get("张三", 10, "男");
        System.out.println(student.name + " 年龄: "
                +student.age + " 性别: " + student.sex);
    }
    public static void main1(String[] args) {
        Dog dog = new Dog();
        /**
         * 我们可以通过 类名.方法名(或成员变量)
         * 来访问创建对象的变量和方法
         */
        dog.name = "lisa";
        dog.age = 10;
        dog.eat();
        dog.bark();


        /*B a = new B();
        B b = new D();
        a.Func();
        b.Func();*/
    }
}





class B {
    public int Func() {
        System.out.print("B");
        return 0;
    }
}
class D extends B {
    @Override
    public int Func() {
        System.out.print("D");
        return 0;
    }
}
